<?php

/**
 * LEAGUEMan
 * 
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$roundresult = new Roundresult();
$roundresult->loadProject($this->project->getID());
$roundresult->loadRoundByOrdering($this->round->getOrdering());
$matches = $roundresult->getResults();

foreach($matches AS $row){
	
	$match = LM::getLMTable("Match");
	$match->populate($row);
	
	if($match->match_info_flag){
?>

	<table class="contentpaneopen" style="border:1px solid #DDD">
		<tr>
			<td class="sectiontableheader" colspan="2">
				<table width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td width="90%">
							<?php echo $row->team1_name . " - " . $row->team2_name;?>
						</td>
						<td width="10%">
							<div align="center">
								<?php echo $row->match_result_0_1 . " : " . $row->match_result_0_2;?>
							</div>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr class="sectiontableentry1">
			<td width="20%">
				<div align="center">
					<?php echo $match->getTeam1()->getName(); ?>
				</div>
			</td>
			<td width="80%">
				<?php $players = $match->getLineupData($match->getTeam1());?>
				<?php $ps = array(); ?>
				<?php foreach($players AS $player):?>
				<?php 	$ps[] = $player->player_name; ?>
				<?php endforeach ?>
				
				<?php echo implode(", ", $ps);?>
			</td>
		</tr>
		<tr class="sectiontableentry1">
			<td width="20%">
				<div align="center">
					<?php echo $match->getTeam2()->getName(); ?>
				</div>
			</td>
			<td width="80%">
				<?php $players = $match->getLineupData($match->getTeam2());?>
				<?php $ps = array(); ?>
				<?php foreach($players AS $player):?>
				<?php 	$ps[] = $player->player_name; ?>
				<?php endforeach ?>
				
				<?php echo implode(", ", $ps);?>
			</td>
		</tr>
		<tr class="sectiontableentry1">
			<td width="20%">
				<div align="center">
					<img src="components/com_leagueman/images/goals.gif" />
				</div>
			</td>
			<td width="80%"><?php $this->plugin("leagueman_get_match_event", $this->project, $match, "cnt_goals", $this->Itemid)?></td>
		</tr>
		<tr class="sectiontableentry2">
			<td width="20%">
				<div align="center">
					<img src="components/com_leagueman/images/yellow.gif" />
				</div>
			</td>
			<td><?php $this->plugin("leagueman_get_match_event", $this->project, $match, "cnt_yellow", $this->Itemid)?></td>
		</tr>
		<tr class="sectiontableentry1">
			<td width="20%">
				<div align="center">
					<img src="components/com_leagueman/images/yellow_red.gif" />
				</div>
			</td>
			<td><?php $this->plugin("leagueman_get_match_event", $this->project, $match, "cnt_yellow_red", $this->Itemid)?></td>
		</tr>
		<tr class="sectiontableentry2">
			<td width="20%">
				<div align="center">
					<img src="components/com_leagueman/images/red.gif" />
				</div>
			</td>
			<td><?php $this->plugin("leagueman_get_match_event", $this->project, $match, "cnt_red", $this->Itemid)?></td>
		</tr>
	</table>
	<br />
<?php
	}
}

?>